<?php

use Biz\model\ShopCategoryClassify;
use Biz\service\BrandPreFecture;

/**
 * 好家气象局
 */
class MeteorologicalAction extends ActionPlugin
{
    const USER_LEVEL = self::LEVEL_NOTHING;


    public function main()
    {
        $list = [
            [
                'tab' => '海尔：令人心动的阳台洗衣房',
                'cover_img' => 'https://img.haohaozhu.cn/Op-imageShow/be0c230f00a40D000ry4sss?iv=1',
                'link' => $this->getLink('https://m.haohaozhu.cn/activity/haier', true),
                'keywords' => ['阳台花房', '阳台萌宠区', '阳台家政灵感', '阳台收纳区', '阳台茶室'],
                'note_id' => $this->getNoteId(['005yn9l000000rc7', '005yp0u0000024qe', '005zsei00000vnzr', '005z49z000003yac', '005z46x000032mes']),
            ], [
                'tab' => '宜家：生活有序，收纳有趣',
                'cover_img' => 'https://img.haohaozhu.cn/Op-imageShow/2d1a430f20a60Hw00ry4rrc?iv=1',
                'link' => $this->getLink('https://lego.haohaozhu.cn/lego/484.html'),
                'keywords' => ['生活有序', '收纳有趣', '宜家收纳风', '收纳方法论', '零食收纳', '客厅收纳'],
                'note_id' => $this->getNoteId(['005xno9000000dcg', '005xmet00000e7pr', '005xq0z00000msld', '005xhsp000002z78', '005xffr000000zw7', '005xm2b000000sg7']),
            ]
        ];
        $this->setSuccess([
            'list' => $list
        ]);
    }

    private function getNoteId(array $ids)
    {
        $index = array_rand($ids);
        return $ids[$index];
    }

    private function getLink($url, $isFullScreen = false)
    {
        if ($isFullScreen) {
            $link = 'niceliving://webview/fullscreen?protego=' . urlencode(base64_encode(json_encode(['url' => $url])));
        } else {
            $link = 'niceliving://webview/normalscreen?protego=' . urlencode(base64_encode(json_encode(['url' => $url])));
        }
        return $link;
    }

}